﻿using NoDriverPrintHelperV1d0.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NoDriverPrintHelperV1d0.Singleton
{
    /// <summary>
    /// 读取ticketPrintCfg.xml的单例模式
    /// </summary>
    public class TicketPrintCfgSingletonV1d0
    {
        private static TicketPrintCfgSingletonV1d0 _instance = null;
        private TicketPrintConfigInfoV1d0 _ConfigInfo = null;
        /// <summary>
        /// 单例模式
        /// </summary>
        public static TicketPrintCfgSingletonV1d0 Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new TicketPrintCfgSingletonV1d0();
                }
                return _instance;
            }
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        private TicketPrintCfgSingletonV1d0()
        {
            LoadData();
        }
        /// <summary>
        /// 装载数据
        /// </summary>
        private void LoadData()
        {
            string currDir = System.IO.Directory.GetCurrentDirectory();
            string filename = currDir + @"\parameter\TicketPrintCfg.xml";
            _ConfigInfo = TicketPrintConfigInfoV1d0.LoadFromXml(filename);
        }

        public TicketPrintConfigInfoV1d0 GetTickerPrintConfigInfo()
        {
            return _ConfigInfo;
        }

    }
}
